import { IFeidaoAiBrowserComponent } from '@dfeidao/atom-web/interfaces';
import set from '@dfeidao/atom-web/local/set';
// tslint:disable-next-line: ordered-imports
import nodejs from '@dfeidao/atom-web/msg/nodejs';
import render from '@dfeidao/atom-web/render/render';
// tslint:disable-next-line: ordered-imports
import set_node_cls from '@dfeidao/atom-web/ui/set-node-cls';
import show from '@dfeidao/atom-web/ui/show';
import p002 from './p002';

export default async function a002(fd: IFeidaoAiBrowserComponent,arr: string) {

	show(fd.data.node);
	const xuanze=fd.data.node.querySelector<HTMLDivElement>('[data-id="xuanze"]');
	set_node_cls(xuanze,'display-n',false);
	const res = await nodejs<{dt: Array<{question_bank_type: string,right_answer: string}>}>('question-bank/zj-000005/s001',{
		filter:{
			question_no:arr
		}
	});
	set (fd,'arr',arr);
	let a="";
	for (let c=0;c < res.dt.length;c++) {
		a += res.dt[c].right_answer;
	 }
	render(fd,res.dt,p002,'p002','inner');
	const xuanxiangA=fd.data.node.querySelector<HTMLInputElement>('[data-id="xuanxiangA"]');
	const xuanxiangB=fd.data.node.querySelector<HTMLInputElement>('[data-id="xuanxiangB"]');
	const xuanxiangC=fd.data.node.querySelector<HTMLInputElement>('[data-id="xuanxiangC"]');
	const xuanxiangD=fd.data.node.querySelector<HTMLInputElement>('[data-id="xuanxiangD"]');
	if (a === "AB") {
		xuanxiangA.checked = true;
		xuanxiangB.checked = true;
	} else if (a === "ABC") {
		xuanxiangA.checked = true;
		xuanxiangC.checked = true;
		xuanxiangB.checked = true;
	} else if (a === "ABCD") {
		xuanxiangA.checked = true;
		xuanxiangB.checked = true;
		xuanxiangC.checked = true;
		xuanxiangD.checked = true;
	} else if (a === "AC") {
		xuanxiangA.checked = true;
		xuanxiangC.checked = true;
	} else if (a === "AD") {
		xuanxiangA.checked = true;
		xuanxiangD.checked = true;
	} else if (a === "ACD") {
		xuanxiangA.checked = true;
		xuanxiangC.checked = true;
		xuanxiangD.checked = true;
	} else if (a === "BC") {
		xuanxiangB.checked = true;
		xuanxiangC.checked = true;
	} else if (a === "BCD") {
		xuanxiangB.checked = true;
		xuanxiangC.checked = true;
		xuanxiangD.checked = true;
	} else if (a === "BD") {
		xuanxiangB.checked = true;
		xuanxiangD.checked = true;
	} else if (a === "CD") {
		xuanxiangC.checked = true;
		xuanxiangD.checked = true;
	}
}
